package com.luobu.javaee.email;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class MailCodeAutoRmSchedule {
    @Autowired
    MailService mailService;

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Scheduled(fixedRate = 60000) // Run every 1 minutes (60,000 milliseconds)
    public void runTask() {
        mailService.removeExpiredCode();
        logger.info("Expired code removed");
    }
}
